package iosr11.example;

import iosr11.Service.ServiceCreator;
import iosr11.Service.ServiceLocatorImpl;
import iosr11.Service.TeacherService;
import iosr11.data.Teacher;

public class TeacherMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ServiceCreator.createService();
		TeacherService servT = (TeacherService) ServiceLocatorImpl.getInstance().getService(Teacher.class);
		
		/*
		Teacher teacher = new Teacher();
		teacher.setName("Adam Jakubiec");
		teacher.setEmail("a.jakubiec@gmail.com");
		teacher.setLecturer(false);
		
		
		System.out.println(servT.createTeacher(teacher.getName(), teacher.getEmail(), teacher.isLecturer()));
		// */
		
		System.out.println(servT.getAllTeachers());
		
		//System.out.println(servT.createTeacher("teacher 3", "teacher3@gmail.com", false));
		/*
		BufferedReader stdin = new BufferedReader(new InputStreamReader(
				System.in));
		DAOLocator factory = DAOLocatorImpl.getInstance();
		String name = new String();
		String email = new String();
		boolean isLecturer = false;
		boolean nowy = true;
		while (true) {
			try {
				System.out.println("N/n - dodanie nowego nauczyciela");
				System.out.println("W/w - wyszukanie nauczyciela");
				System.out.println("Inny klawisz - wyjście");
				name = stdin.readLine();
				if (name.equals("N") || name.equals("n"))
					nowy = true;
				else if (name.equals("W") || name.equals("w"))
					nowy = false;
				else
					throw new Exception();
			} catch (Exception e) {
				System.err.println("Wyjscie");
				System.exit(0);
			}
			// dodawanie nowego studenta
			if (nowy) {
				try {
					System.out.print("Podaj nazwisko i imie: ");
					name = stdin.readLine();
					System.out.print("Podaj e-mail: ");
					email = stdin.readLine();
					System.out.print("Czy wykladowca(T): ");
					String tmpInt = stdin.readLine();
					if (tmpInt.equals("T") || tmpInt.equals("t"))
						isLecturer = true;
					else
						isLecturer = false;
					System.out.println("Nazwisko i Imie: " + name);
					System.out.println("e-mail: " + email);
					System.out.println("Wykladowca: " + isLecturer);
					System.out.println("Czy dane sa poprawn?(T)");
					tmpInt = stdin.readLine();
					if (!(tmpInt.equals("T") || (tmpInt.equals("t"))))
						throw new Exception();
					if ((name.length() < 1) || (email.length() < 1))
						throw new Exception();
					Teacher teacher = new Teacher(null,name,email,null,isLecturer);
					System.out.println(((TeacherDAO)factory.getDAO(Teacher.class)).add(teacher));
				} catch (Exception e) {
					System.err.println("Przerwano");
				}
			} else {
				// wyszukiwanie po loginie
				try {
					System.out.print("Podaj login lub nazwisko i imie: ");
					name = stdin.readLine();
					System.out
							.println(((TeacherDAO)factory.getDAO(Teacher.class)).getByLogin(name));
				} catch (Exception e) {
					System.err.println("Przerwano");
				}
			}
		}
		//*/
	}

}
